package models

import "github.com/beego/beego/v2/client/orm"

/**
create table video_call_materials_audit_detail(
    id bigint auto_increment primary key,
    anchor_id      bigint       default 0  not null comment '主播id',
    audit_id       bigint       default 0  not null comment '审核id,video_call_materials_audit.id',
    materials_type int          default 20 not null comment '资料类型（10:认证图片 11:相册图片 20:问候语）',
    content        varchar(512) default '' not null comment '资料内容',
    content_type   int          default 0  not null comment '内容类型（0:文本  1:图片  2:语音  3:视频）',
    file_path_hash     varchar(32)  default '' not null comment '文件地址hash(用于文件清理时判断是否被未删除资料引用)',
    create_time    bigint       default (unix_timestamp())  not null comment '创建时间',
    update_time    bigint       default 0  not null comment '更新时间',
    index idx_anchor_id(anchor_id),
    index idx_audit_id(audit_id)
)engine=innodb default charset=utf8mb4 comment='视频资料审核详情表';
*/

type Video_call_materials_audit_detail struct {
	Id            int64  `orm:"auto" json:"id"`
	AnchorId      int64  `json:"anchor_id"`
	AuditId       int64  `json:"audit_id"`
	MaterialsType int    `json:"materials_type"`
	Content       string `json:"content"`
	FilePath      string `json:"file_path"`
	ContentType   int    `json:"content_type"`
	FilePathHash  string `json:"file_path_hash"`
	CreateTime    int64  `json:"create_time"`
	UpdateTime    int64  `json:"update_time"`
}

func init() {
	orm.RegisterModel(new(Video_call_materials_audit_detail))
}

func GetVideo_call_materials_audit_detailByAnchor(anchorId int64, auditId int64) (m []Video_call_materials_audit_detail, err error) {
	o := orm.NewOrm()
	m = []Video_call_materials_audit_detail{}
	fields := []string{"id", "materials_type", "content", "content_type", "file_path"}
	_, err = o.QueryTable(new(Video_call_materials_audit_detail)).Filter("anchor_id", anchorId).Filter("audit_id", auditId).All(&m, fields...)
	return
}

func AddVideo_call_materials_audit_detailBatch(m *[]Video_call_materials_audit_detail) (num int64, err error) {
	o := orm.NewOrm()
	num, err = o.InsertMulti(len(*m), m)
	return
}
